#include "Shm.h"
#include "definiciones.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>


void Shm::map(){
    base = shmat(id, NULL, 0);
}

void Shm::unmap(){
    shmdt(base);
}

Shm::Shm(int id){
    this->id = shmget(ftok(FTOK_PATH, id),SHM_TAMANIO, IPC_CREAT|0666);
    map();
}

void* Shm::getBase(){
    return base;
}

Shm::~Shm(){
    unmap();
    //    shmctl(id, IPC_RMID, NULL);
}

